//
//  XiaoKaiRaidersViewController.m
//  Project_A
//
//  Created by 凯 on 15/7/14.
//  Copyright (c) 2015年 zhoukaidong. All rights reserved.
//
//攻略详情页面


#import "XiaoKaiRaidersViewController.h"
#import "BaseHeader.h"
//攻略详情页面

@interface XiaoKaiRaidersViewController ()
<
UIWebViewDelegate
>

@property (nonatomic , retain)UIView *Navview;

@property (nonatomic , retain)UILabel *Navlabel;

@property (nonatomic , retain)UIButton *back;

@property (nonatomic , retain)UIWebView *webview;


@end

@implementation XiaoKaiRaidersViewController
- (void)dealloc
{
    [_labeltext release];
    [_webview release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatNav];
    [self creatwebview];
}
-(void)creatwebview
{
    self.webview = [[[UIWebView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH,SCREEN_HEIGHT - 64)] autorelease];
    NSURLRequest *requset = [NSURLRequest requestWithURL:[NSURL URLWithString:self.webviewrequest]];
    self.webview.delegate = self;
    [self.webview loadRequest:requset];
    [self.view addSubview:self.webview];
    
}
-(void)creatNav
{
    self.Navview = [[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 20 )] autorelease];
    self.Navview.backgroundColor = NAVCOLOR;
    [self.view addSubview:self.Navview];
    self.Navlabel = [[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH / 21.3, 20, SCREEN_WIDTH, 44)] autorelease];
   // self.Navlabel.alpha = 0;
    self.Navlabel.backgroundColor = NAVCOLOR;
    self.Navlabel.text = self.labeltext;
    self.Navlabel.numberOfLines = 0;
    self.Navlabel.font = [UIFont systemFontOfSize:17];
    self.Navlabel.textColor = [UIColor whiteColor];
    self.Navlabel.textAlignment = NSTextAlignmentCenter;
    UIView *view = [[[UIView alloc]initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH / 21.3, 44)] autorelease];
    view.backgroundColor = NAVCOLOR;
    [self.view addSubview:view];
    [self.view addSubview:self.Navlabel];
    [self getbutton];
    
}
-(void)getbutton
{
    self.back = [UIButton buttonWithType:UIButtonTypeCustom];
    self.back.backgroundColor = [UIColor clearColor];
    self.back.frame = CGRectMake(10, 32, 20, 20);
    [self.back setBackgroundImage:[UIImage imageNamed:@"iconfont-xiangzuo@2x"] forState:UIControlStateNormal];
    [self.back addTarget:self action:@selector(getback) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.back];
    [self.view bringSubviewToFront:self.back];
}
-(void)getback
{
    [self.navigationController popViewControllerAnimated:YES];
    //    NSLog(@"走走走 回家喽");
    
}
//判断用户交互方式的方法


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    switch (navigationType)
    {
            //点击连接
        case UIWebViewNavigationTypeLinkClicked:
        {
           // [self.imageview removeFromSuperview];
            NSString *str = self.webview.request.URL.absoluteString;
            [[UIApplication sharedApplication]openURL:[NSURL URLWithString:str]];
       





#pragma mark - 不启动本身的跳转
  //       [self backaaa];
//            [self.webview  stringByEvaluatingJavaScriptFromString:@"webView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) {  TODO Auto-generated method stub view.loadUrl(url); return true; } });"];
            NSLog(@"clicked");
        }
            break;
            //提交表单
        case UIWebViewNavigationTypeFormSubmitted:
        {
            NSLog(@"submitted");
        }
        default:
            break;
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
